﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CarExam.Common;
using CarExam.DAL;
using System.Data;

namespace CarExam.BLL
{
    public class ItemBank
    {
        ItemBankDAL _ibdal = new ItemBankDAL();

        /// <summary>
        /// 获取题库数据
        /// </summary>
        /// <param name="type">1:顺序考试 2:随机考试</param>
        /// <param name="startindex">如果是顺序考试，则此参数为顺序取题的起始位置；
        /// 如果是随机考试，则此参数为随机取题时对应的题库表中的主键id
        /// </param>
        public DataTable GetItemBank(int type, int startindex)
        {
            return _ibdal.GetItemBank(type, startindex);
        }

        /// <summary>
        /// 添加错题到错题本中
        /// </summary>
        /// <param name="uid">当前考生id</param>
        /// <param name="tid">题号id</param>
        public bool InsertErrorItem(int uid, int tid, int isok = 0)
        {
            return _ibdal.InsertErrorItem(uid, tid, isok);
        }

        /// <summary>
        /// 获取错题本中的所有数据
        /// </summary>
        /// <param name="uid">当前考试的id</param>
        /// <param name="type">0:错题练习 1:模拟考试</param>
        public DataTable GetErrorItem(int uid, int type = 0)
        {
            return _ibdal.GetErrorItem(uid, type);
        }

        /// <summary>
        /// 获取题库中的总记录数
        /// </summary>
        public int GetItemBankCount()
        {
            return _ibdal.GetItemBankCount();
        }

        /// <summary>
        /// 清除错题库
        /// </summary>
        public int ClearErrorItem()
        {
            return _ibdal.ClearErrorItem();
        }

        public DataTable GeterrorRate(int tid)
        {
            return _ibdal.GeterrorRate(tid);
        }
    }
}
